package com.feng.zhihao.demo.springbatch.config;

import javax.sql.DataSource;

import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

@Configuration
public class QuartzConfig {
	
	@Bean
	@ConfigurationProperties(prefix="spring.quartz")
	public SchedulerFactoryBean getStdSchedulerFactory(@Autowired DataSource dataSource) throws SchedulerException {
		SchedulerFactoryBean factoryBean=new SchedulerFactoryBean();
		factoryBean.setDataSource(dataSource);
		factoryBean.setOverwriteExistingJobs(true);
		factoryBean.setStartupDelay(30);
//		factoryBean.setConfigLocation(new ClassPathResource(fileName));
		return factoryBean;
	}
	
}
